package 堆;


import java.util.ArrayList;
import java.util.Random;

/**
 * @author shy_black
 * @date 2019/4/25 13:17
 * @Description:
 */
public class test {
    public static void main(String[] args) {
        int n = 100;
        MaxHeap<Integer> heap = new MaxHeap<>();
        Random random = new Random();
        for(int i = 0;i < n; i++)
            heap.add(random.nextInt(Integer.MAX_VALUE));
        //ArrayList<Integer> arr = new ArrayList<>(n);
        Integer[] arr= new Integer[n];
        for(int i = 0;i < n;i++)
            arr[i] = heap.extractMax();
        for(int i = 1;i < n;i++)
            if(arr[i-1] < arr[i])
                throw new IllegalArgumentException("Error");
        System.out.println("堆测试正常");


        System.out.println("-----我是分割线------");

        testHeapfiy(arr);

    }
    public static void testHeapfiy( Integer[] data) {
        MaxHeap<Integer> heap = new MaxHeap<>();
        heap.heapify(data);
        for(Integer i : data)
            System.out.println(i+"_");
    }

}
